<template>
	<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption"  @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
		<stop isBack>
			<view slot="content">我的维修任务</view>
		</stop>
		<view class="bcf padlr3 padtb2 bdtso">
			<search class="fs8 tac" placeholder="故障 \ 单号 \ 设备名称 \ 编码 \ 型号"  v-model="search" @search="doSearch()"></search>
		</view>
		<view class="flrc bcf pad3 bdtso bdbso fs8">
			<view class="flex1"><scondition @input="reload()" model="MachineBreakStatus" v-model="where.eq.status" label="订单状态"></scondition></view>
			<view class="flex1"><scondition @input="reload()" model="MachineBreakEmergency" v-model="where.eq.emergency" label="紧急程度"></scondition></view>
			<view class="flex1"><scondition @input="reload()" model="MachineBreakLevel" v-model="where.eq.level" label="故障等级"></scondition></view>
		</view>
		<view class="padlr3">
			<view class="bcf pos-r mart3 round2 shadow ofh" 
			@tap="mySlide(index)" 
			v-for="item,index in data" :key="item.id">
				<breaks class="mar2" :item="item.breakOrder" :showAngle="false"></breaks>
				<fix-order class="mar2" :item="item" :showAngle="false"></fix-order>
				<sslide ref="mySlideBox" >
					<view class="bg-orange flex-c flex-fill pad2 round3">
							<view class="w100 flex1 flcc pos-r pad5" 
								@tap="goto('/pages/machine/break_order_info?id='+item.breakOrder.id)">
								查看<ripple></ripple>
							</view>
							<view class="w100 flex1 flcc pos-r pad5 bdtso" v-if="!objval(item,['breakOrder','status','isLocked'])"
								@tap="goto('/pages/machine/fix_order_confirm?id='+item.id)">
								处理<ripple></ripple>
							</view>
							<view class="w100 flex1 flcc pos-r pad5 bdtso" v-if="!objval(item,['breakOrder','status','isLocked'])"
								@tap="goto('/pages/machine/fix_order_give_out?id='+item.id)">
								移交<ripple></ripple>
							</view>
							<view class="w100 flex1 flcc pos-r pad5 bdtso" v-if="!objval(item,['breakOrder','status','isLocked'])"
								@tap="goto('/pages/store/store_out_form?bsn='+item.breakOrder.sn + '&machine=' + item.breakOrder.machine.id)">
								领料<ripple></ripple>
							</view>
							<view class="w100 flex1 flcc pos-r pad5 bdtso" v-if="!objval(item,['breakOrder','status','isLocked'])"
								@tap="goto('/pages/machine/fix_order_cancel?id='+item.id)">
								取消<ripple></ripple>
							</view>
					</view>
				</sslide>
			</view>
		</view>
		<loading :loading="myIsLoading"></loading>
	</scroll>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import List from '../../assets/js/list.js'
	import breaks from '../../templete/machine/machine_break_list_com.vue'
	import fixOrder from '../../templete/machine/machine_fix_order_item.vue'
	export default {
		mixins:[MescrollMixin],
		components:{fixOrder,breaks},
		data() {
			//默认只获取能需要处理的
			let status = this.$com.getLocData('DEFAULT_BREAK_ORDER_STATUS_ID')
			status = this.isbool(status)?status:0
			
			let list = new List()
			return {
				list,
				where:{
					eq:{
						status:status,
						emergency:'',
						level:'',
					}
				},
				search:"",
				data:[],
				curActionId:0,
				lastActionId:0
			}
		},
		methods: {
			reload(){
				this.showLoading()
				this.data = []
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			doSearch(){
				this.showLoading()
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			showAction(id){
				this.lastActionId = this.curActionId 
				this.curActionId = this.curActionId == id?0:id
				this.log(this.lastActionId)
				this.log(this.curActionId)
			}
			// ,getIt(id){//接取任务
			// 	this.log(id)
			// 	//创建数据
			// 	let data = {
			// 		breakOrder:'/api_/machine_breaks/' + id,
			// 	}
			// 	this.showLoading()
			// 	this.$api.post('/api/machineFixOrders',data,(res)=>{
			// 		this.log(res)
			// 		this.clearLoading()
			// 		this.reload()
			// 	})
			// }
		},
		mounted() {
			this.list.initMescroll(this).setUrl('/api/user/machineFixOrders').setData({
				_order:{id:"DESC"},
				_where:this.where,
				_search:this.search,
			}).setCbFunc(res=>{
				this.data = res
				this.clearLoading()
			}).reload()
		},
		onShow() {
			this.list.reload()
		},
	}
</script>

<style>

</style>
